/**
* form-block.js
*
* still don't know how to write proper jsdoc :(
* 
*/
$(document).ready(function(){
	$.ajaxSetup({ 
		'beforeSend': function(xhr) {
			xhr.setRequestHeader("Accept", "text/javascript")
		} 
	}); 
	
    $('.update-container form').bind('submit', function(event) {
        
        jQuery.blockUI({ message: 'Saving...' }); 
        //block the UI
        
        var form =  $(event.target);
        //the form

        var action = form.attr('action');
        if (action == '') {
        	action = location.href;
        }
        
        $.ajax({
        	url: action,
        	//url
        	data: form.serialize(),
        	//form data as params,
        	type: 'POST',
        	success: function() {
        		jQuery.unblockUI();
        	},
        	error: function() {
        		jQuery.unblockUI();
        	}
        });
        
        
        return false;
        //don't really submit the form... no no, that wouldn't be as fun    
    });
});